//签名信息
var bip39 = require('bip39')
var bitcoin = require('bitcoinjs-lib')
var ecc = require('tiny-secp256k1')
var util = require('ethereumjs-util')
var bs58check = require('bs58check')
const secp256k1 = require('secp256k1')
var bitcoinMessage = require('bitcoinjs-message')

var network = bitcoin.networks.testnet

   var wif = 'cSkTBuc1aSdzcPE4AXcQHpWD6uedRd3t6xjeWLvjP6LeDZUBPkGt'
   var keyPair = bitcoin.ECPair.fromWIF(wif,network) // 导入私钥

    var pubKey = keyPair.getPublicKeyBuffer() // 返回Buffer对象
    var address = keyPair.getAddress() // 返回String地址
	console.log(pubKey.toString('hex')) // 02或03开头的压缩公钥
	console.log(address) // 1开头的地址

var privateKey = keyPair.d.toBuffer(32)
var decoded = bs58check.decode(wif)

console.log(privateKey.toString('hex'))
console.log(decoded)
//let s = "\x18Bitcoin Signed Message:\n"

var message = '123456'

var signature = bitcoinMessage.sign(message, privateKey, keyPair.compressed)
console.log(signature.toString('base64'))